<template>
	<view class="page">
		<view class="vimg">
			<image class="img1" src="/static/home/wifi.png" mode=""></image>
		</view>
		<image class="img" src="/static/home/open.png" mode=""></image>
		<view class="vtext">
			<view class="vtext1">
				<text>欢迎使用</text>
			</view>
			<view class="vtext2">
				<text>WIFI安全一键连</text>
			</view>
		</view>
		<view class="vbtn" v-if="isShow">
			<button plain @tap="goHome">跳过</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLoading: false,
				isShow:false
			}
		},
		onShow() {
			uni.showLoading({
				title: '初始化...',
			});
			this.isLoading = true;
			this.$refs.adRewardedVideo.load();
		},
		methods: {
			showAd() {
				let that = this
				if (this.isLoading) {
					return
				}
				// this.$refs.adRewardedVideo.show();
				uni.hideLoading()
				setTimeout(function(){that.isShow = true}, 5000)
			},
			onadload(e) {
				this.isLoading = false;
				console.log('广告数据加载成功');
				this.showAd()
			},
			onadclose(e) {
				const detail = e.detail
				// 用户点击了【关闭广告】按钮
				if (detail && detail.isEnded) {
					// 正常播放结束
					console.log("onClose " + detail.isEnded);
				} else {
					// 播放中途退出
					console.log("onClose " + detail.isEnded);
				}
				//this.isLoading = true;
				//this.$refs.adRewardedVideo.load();
			},
			onaderror(e) {
				// 广告加载失败
				console.log(e.detail);
				this.isLoading = false;
			},
			goHome(){
				uni.switchTab({
					url:"/pages/home/home"
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.ad-error {
		color: orangered;
		margin-top: 5px;
	}
	.page{
		height: 100vh;
		width: 100%;
		
		.img{
			height: 100%;
			width: 100%;
		}
		
		.img1{
			width: 150rpx;
			height: 150rpx;
		}
		
		.vtext1{
			color: #fff;
			font-size: 50rpx;
		}
		.vtext2{
			color: #fff;
			font-size: 50rpx;
			margin-top: 60rpx;
		}
		.vtext{
			width: 100%;
			height: 200rpx;
			position: absolute;
			top: 40%;
			text-align: center;
		}
		.vimg{
			width: 100%;
			height: 200rpx;
			text-align: center;
			position: absolute;
			top: 20%;
		}
		.vbtn{
			position: absolute;
			bottom: 100rpx;
			right: 50rpx;
			color: #fff;
		}
	}
</style>